var t = getApp();

Page({
    data: {
        classify_name: "",
        isOpen: "",
        judgeState: !0,
        classify_id: "",
        store_id: "",
        level: ""
    },
    onLoad: function(t) {
        t.classify_id && this.setData({
            classify_id: t.classify_id
        }), t.store_id && this.setData({
            store_id: t.store_id
        }), t.level && this.setData({
            level: t.level
        }), this.getJson();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getJson: function() {
        var a = this, e = t.getNetAddresss("plugin.store-cashier.frontend.store.goods-category.detail-category"), s = {
            id: a.data.classify_id
        };
        t._postNetWork({
            url: e,
            showToastIn: !1,
            data: s,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    classify_name: e.data.name
                }), 1 == e.data.enabled ? a.setData({
                    isOpen: "1"
                }) : 0 == e.data.enabled && a.setData({
                    isOpen: "0"
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    classifyNameinp: function(t) {
        var a = t.detail.value;
        this.setData({
            classify_name: a
        });
    },
    isOpenChange: function(t) {
        var a = t.detail;
        this.setData({
            isOpen: a
        });
    },
    sureEdit: function() {
        var a = "";
        "1" == this.data.isOpen ? a = 1 : "0" == this.data.isOpen && (a = 0);
        var e = this;
        if (e.judge(), 1 == e.data.judgeState) {
            var s = {
                store_id: e.data.store_id,
                name: e.data.classify_name,
                enabled: a,
                id: e.data.classify_id,
                level: e.data.level
            }, i = t.getNetAddresss("plugin.store-cashier.frontend.store.goods-category.edit-category");
            t._postNetWork({
                url: i,
                showToastIn: !1,
                data: s,
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? wx.showToast({
                        title: "修改成功",
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateTo({
                                    url: "/packageC/o2o/GoodsClassify/GoodsClassify?store_id=" + e.data.store_id
                                });
                            }, 1500);
                        }
                    }) : wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {}
            });
        } else wx.showToast({
            icon: "none",
            title: "分类信息不完整",
            duration: 1500
        });
    },
    judge: function() {
        this.setData({
            judgeState: !0
        }), "" != this.data.classify_name && "" != this.data.isOpen || this.setData({
            judgeState: !1
        });
    }
});